import 'package:flutter/material.dart';

///灰色蒙层
class ColorFilteredWidget extends StatelessWidget {
  final List<double>? colorList;
  final Widget child;
  final bool? enableGrayMode;

  ColorFilteredWidget({
    Key? key,
    this.colorList,
    required this.child,
    this.enableGrayMode,
  }) : super(key: key);

  final List<double> list = [
    0.2126, 0.7152, 0.0722, 0, 0,
    0.2126, 0.7152, 0.0722, 0, 0,
    0.2126, 0.7152, 0.0722, 0, 0,
    0, 0, 0, 1, 0,
  ];

  @override
  Widget build(BuildContext context) {
    if (enableGrayMode == true) {
      return ColorFiltered(
        colorFilter: ColorFilter.matrix(colorList?.isNotEmpty==true ? colorList! : list),
        child: child,
      );
    }
    return child;
  }
}
